<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>list</title>
<#include "/admin/include/head.htm">
<script type="text/javascript">
    var grid;
    $(function () {
        grid = $("#maingrid").ligerGrid({
            columns: [
				{display: 'ID', name: 'id', align: 'left', width:80},
				{display: '标签名称', name: 'name', align: 'center', width: 200}
			],  
			pageSize:20, 
			url: '${base}/admin/b2c/tag/queryData.jhtml',
			toolbar: {}, 
			width: '100%', 
			height:'100%', 
			enabledSort: true
        });
        $("#pageloading").hide();
		LG.loadToolbar(grid);
		
		//绑定搜索按钮
		LG.search(grid);
    });
	
	function add(){
		top.f_addTab(null, '新增标签', '${base}/admin/b2c/tag/add.jhtml?parentMenuNo=b2c_tag_list');
	}
	
	function edit() {
		var selecteds = grid.getSelecteds();
		if (selecteds.length != 1) { 
			LG.tip('请选择一行记录!'); 
			return; 
		}
		var id = selecteds[0].id;
		if(top.f_isTabItemExist("tag" + id)){
			top.f_switchTab("tag" + id);
		}else{
			top.f_addTab("tag" + id, '修改标签[' + selecteds[0].name + ']', '${base}/admin/b2c/tag/edit.jhtml?parentMenuNo=tag_list&id=' + id);
		}
	}
	
	function f_delete() {
		var selecteds = grid.getSelecteds();
	    if (selecteds.length > 0) {
	    	jQuery.ligerDialog.confirm('确定删除吗？', function (confirm) {
      			if (confirm){
					LG.ajax({
						url: base + '/admin/b2c/tag/delete.jhtml',
			            loading: '正在删除中...',
			            data: { ids: LG.getIds(selecteds) },
			            success: function () {
							LG.showSuccess('删除成功');
			                f_reload();
			            },
			            error: function (message) {
							LG.showError(message);
			            }
			        });
			    }
			});
		} else {
			LG.tip('请选择行!');
	    }
	}
	
	//关联商品
	function correlateGoods(){
		var selecteds = grid.getSelecteds();
		if(selecteds.length == 1){
			$.ligerDialog.open({
				title:"关联商品-"+selecteds[0].name, height: 650,width:1250,
				url: base + '${base}/admin/b2c/goodsTag/correlate.jhtml?tagId='+selecteds[0].id,isResize: true,
				buttons: [
					{ text: '取消', onclick: function (item, dialog) { dialog.hide();}}
				]
			});
		}else{
			LG.tip('请选择一行!');
		}
	}
</script>
</head>
<body style="padding:10px; overflow:hidden;">
	<div id="functions">
		<div class="clearfix">
			<div style="float:left;">
				<span>
					标签名称：<input type="text" class="formText" name="search_LIKE_name"/>
				</span>
				<input type="button" id="search" class="button" value="搜索"/>
				<a href="#" id="search_btn_reset" face="Wingdings 3">解除搜索,显示全部数据</a>
			</div>
		</div>
	</div>
	<div id="maingrid" style="margin:0; padding:0"></div>
</body>
</html>